package com.qk.mapper;

import com.qk.dto.CourseDto;
import com.qk.entity.Course;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseMapper {
    //查询课程列表
    List<Course> selectList(CourseDto courseDto);
    //删除课程
    @Delete("delete from course where id=#{id}")
    void delete(Integer id);
    //添加课程
    @Insert("insert into course(subject,name,price,target,description,create_time,update_time) " +
            "values (#{subject},#{name},#{price},#{target},#{description},#{createTime},#{updateTime}) ")
    void insert(Course course);
    //根据ID查询
    @Select("select id, subject, name, price, target, description, create_time, update_time from course where id= #{id}")
    Course selectByID(Integer id);
    //修改课程
    void upDate(Course course);
    //查询所有课程
    @Select("select id, subject, name, price, target, description, create_time, update_time from course")
    List<Course> selectAllList();
    //根据课程类别查询
    @Select("select id, subject, name, price, target, description, create_time, update_time from course where subject= #{subject} order by update_time desc ")
    List<Course> subjectList(Integer subject);
}
